<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>7_1_2-1-Vue中的响应式对象-基本功能</title>
</head>

<body>


    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <div id="Application"></div>
    <script>
        const App = Vue.createApp({
            //进行组件数据初始化
            setup() {
                //数据
                let myData = {
                    value: 0
                }
                //按钮的单击方法
                function click() {
                    myData.value += 1
                    console.log(myData.value)
                }
                //数据返回
                return {
                    myData,
                    click
                }
            },
            //模板中可以直接使用setup方法中定义的数据和函数
            template: `
        <h1>测试数据：{{ myData.value }}</h1>
        <button @click="click">点击</button>
        `
        })
        App.mount("#Application")
    </script>
</body>

</html>